# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=picom
pkgver=10.2
pkgrel=1
pkgdesc="X Compositor (a fork of compton)"
url="https://github.com/yshui/picom"
# s390x: tests hang
arch="all !s390x"
license="MIT AND MPL-2.0"
makedepends="
	asciidoc
	dbus-dev
	libconfig-dev
	libdrm-dev
	libev-dev
	libx11-dev
	libxcomposite-dev
	libxdamage-dev
	libxdg-basedir-dev
	libxinerama-dev
	libxrandr-dev
	mesa-dev
	meson
	pcre-dev
	pixman-dev
	uthash-dev
	xcb-util-image-dev
	xcb-util-renderutil-dev
	"
checkdepends="
	dbus-x11
	libffi-dev
	py3-dbus-next
	py3-wheel
	py3-xcffib
	python3
	python3-dev
	xvfb-run
	"
subpackages="$pkgname-doc"
source="picom-$pkgver.tar.gz::https://github.com/yshui/picom/archive/v$pkgver.tar.gz"

# one test fails
[ "$CARCH" = "ppc64le" ] && options="$options !check"

replaces="compton" # Backwards compatibility
provides="compton=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	abuild-meson \
		-Db_lto=true \
		-Dwith_docs=true \
		build
	meson compile -C build
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C build

	mkdir -p "$pkgdir/usr/share/doc/picom"
	install -m644 README* "$pkgdir/usr/share/doc/picom/"
	install -D -m644 "picom.sample.conf" "$pkgdir/etc/xdg/picom.conf.example"
}

check() {
	export XDG_RUNTIME_DIR="$(mktemp -d -p "$builddir")"
	xvfb-run -a build/src/picom --config picom.sample.conf --no-vsync --diagnostics
	xvfb-run -a ./tests/run_tests.sh build/src/picom
}

sha512sums="
9c0351fbe8a9e76533243c8e76f8e7d10c1e49292f1c8e6c06f31fb0b512542a67970abe803d061c953546ff8d3e704488c263002a5a831f68deb010caee481d  picom-10.2.tar.gz
"
